//
//
// Adventure screen handler for the Shrines
//
// L. Dean Gibson II  2/14/01
//
//

#ifndef ADV_SHRINE_H_INCLUDED
#define ADV_SHRINE_H_INCLUDED

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <bitset>
#include "bool_array.h"
#include "linkage_data.h"
#include "spell.h"
#include "spell_set.h"
#include "stationary_adventure_object.h"

enum t_spell;
enum t_skill_mastery;
enum t_skill_type;
enum t_town_type;

// -------------------------------------------------------
// shrine as it appears on the adventure map
// -------------------------------------------------------
class t_adv_shrine : public t_stationary_adventure_object
{
public:
	// Constructor
	t_adv_shrine( t_town_type alignment, int spell_level, t_spell spell );
	t_adv_shrine(  std::string const& source, t_qualified_adv_object_type const& type );

	// Member functions
	virtual void			activate_trigger(
								t_army*					army,
								t_adv_map_point const&	point, 
								t_direction				direction,
								t_adventure_frame*		frame );
	virtual float			ai_value( t_adventure_ai const& ai, t_creature_array const& army, int move_cost ) const;
	t_town_type				get_alignment() const;
	virtual std::string     get_balloon_help() const;
	t_skill_mastery         get_skill_level() const;
	t_skill_type            get_skill_type() const;
	int						get_spell_level() const;
	virtual int             get_version() const;
	virtual void            initialize( t_adventure_map& map );
	virtual bool			read( std::streambuf&						stream, 
								  t_qualified_adv_object_type const&	type,
					              int									version );
	virtual bool			read_from_map(
								std::streambuf&		buffer,
								t_progress_handler* );
	virtual void			right_click(
								t_mouse_event const&	event,
								t_adventure_frame*		adventure_frame );
	virtual bool            write( std::streambuf& stream ) const;
private:
	std::string replace_text( std::string text ) const;

	t_spell      m_pick_spell; // save a spell at placement to give when army touches us
	t_spell_set  m_spell_mask; // Mask from editor. Don't use after initialize()
	t_bool_array m_visited;
};

inline t_skill_mastery t_adv_shrine::get_skill_level() const
{
	return t_skill_mastery( get_major_subtype() );
}

inline t_town_type t_adv_shrine::get_alignment() const
{
	return t_town_type( get_minor_subtype() );
}

inline int t_adv_shrine::get_spell_level() const
{
	return get_major_subtype() + 1;
}

// -------------------------------------------------------
// t_random_adv_shrine class
// -------------------------------------------------------

class t_random_adv_shrine : public t_stationary_adventure_object
{
public:
	t_random_adv_shrine( std::string const & source );
	// Member functions
	int					get_spell_level() const;
	virtual bool		read_from_map( std::streambuf &		buffer,
							           t_progress_handler * );
	virtual void		place( t_adventure_map &		map,
							   t_adv_map_point const&	point );
	virtual bool        preplacement( t_adventure_map& map, int pass );

private:
	// Data members
	t_town_type		m_alignment; // Chosen in preplacement()
	t_linkage_data  m_linkage_info;
	t_spell_set		m_spell_mask;
};

inline int t_random_adv_shrine::get_spell_level() const
{
	return get_major_subtype() + 1;
}

#endif // ADV_SHRINE_H_INCLUDED
